package com.qianxx.component.activity.recycleview.pull_recyclerview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.qianxx.component.R;
import com.qianxx.viewlibrary.recyclerview.pull.AbRefreshMoreView;

/**
 * 上拉加载更多视图
 */
public class LoadMoreView extends AbRefreshMoreView {
    private TextView mTvTip;

    public LoadMoreView(Context context) {
        super(context);
    }

    @Override
    protected void onNormalState() {
        mTvTip.setText("上拉加载更多");
    }

    @Override
    protected void onLoadingMore() {
        mTvTip.setText("正在加载...");
    }

    @Override
    protected void onResultSuccess() {
        mTvTip.setText("加载成功");
        onResult();
    }

    @Override
    protected void onResultFail() {
        mTvTip.setText("加载失败");
        onResult();
    }

    private void onResult() {
        mTvTip.setVisibility(VISIBLE);
    }

    @Override
    protected View onCreateView(Context context) {
        return LayoutInflater.from(context).inflate(R.layout.view_load_more, null);
    }

    @Override
    protected void initView() {
        mTvTip = (TextView) findViewFromId(R.id.tv_tip);
    }
}
